package com.youboy.wechatapi.utils.json;

import org.codehaus.jackson.annotate.JsonAutoDetect;
import org.codehaus.jackson.annotate.JsonMethod;
import org.codehaus.jackson.map.DeserializationConfig;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.map.SerializationConfig;
import org.codehaus.jackson.map.annotate.JsonSerialize;

/**
 * @ProjectName：wechatapi
 * @author：冉尧（Yvan）
 * @CreateTime：2014年9月29日 上午10:31:03
 * @Remarks：
 */
public class JacksonMapper {

	private static final ObjectMapper mapper = new ObjectMapper();
	static {
		mapper.setVisibility(JsonMethod.FIELD, JsonAutoDetect.Visibility.ANY);
		mapper.configure(SerializationConfig.Feature.INDENT_OUTPUT, true);
		mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
		mapper.setSerializationInclusion(JsonSerialize.Inclusion.NON_NULL);
	}

	private JacksonMapper() {

	}

	/**
	 * 
	 * @return
	 */
	public static ObjectMapper getInstance() {
		return mapper;
	}
}
